<?php
/**
 *  
 * @package package_name
 * @author Mervin.Wong<mervin0502@163.com>
 * @copyright
 * @license  http://www.apache.org/licenses/LICENSE-2.0
 * @version 0.1.0
 * @date 2013-3-6下午8:57:36
 *
 */
/**
 * CanGoo Option Model
 * 博客设置模型
 * 
 */ 
 
 class Option_model extends CI_Model{
 	
 	/**
 	 * 构造函数
 	 */
 	public function __construct(){
 		parent::__construct();
 		$this->load->database();
 	}
 	
 	/**
 	 * 获取一条记录
 	 * @access public
 	 * @param array $field table field
 	 * @param string $table table name
 	 * @param array $conditions where condition
 	 * @return array|bool description
 	 */
 	public function get_one($field, $table, $conditions){
 		$this->db->select($field);
 		$this->db->from($table);
 		foreach ( $conditions as $k => $v ) {
       	$this->db->where($k, $v);
		}
 		$query = $this->db->get();
 		if($query->num_rows > 0){
 			return $query->row_array();
 		}else{
 			return false;
 		}
 	}
 	
 	/**
 	 * 插入一条记录
 	 * @access public
 	 * @param array $field description
 	 * @param string $table description
 	 * @return int|bool description
 	 */
 	public function insert($field, $table){
 		$this->db->insert($table, $field);
 		if($this->db->affected_rows() > 0){
 			return $this->db->insert_id();
 		}else{
 			return false;
 		}
 	}
 	
 	/**
 	 * 更新一条记录
 	 * @access public
 	 * @param array $field description
 	 * @param string $table description
 	 * @param array $conditions description
 	 * @return bool description
 	 */
 	public function update($field, $table, $conditions){
 		foreach($conditions as $k=>$v){
 			$this->db->where($k, $v);
 		}
 		$this->db->update($table, $field);
 		if($this->db->affected_rows() > 0){
 			return true;
 		}else{
 			return false;
 		}
 	}
 	
 	
 }
 /* End of file:option_model.php*/
 /* Location : ./admin/models/blog/option_model.php */




